﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
using DQYT.HTDZ.BLL;
using DQYT.HTDZ.Model;

namespace DQYT.HTDZ.Web.Views.SystemManage
{
    public partial class Pull : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            #region
            try
            {
                lblMsg.Text = "";
                BDMenuBLL menuBLL = new BDMenuBLL();
                lblPath.Text = menuBLL.GetTitlePath(Request["mnu_id"]);
                if (!IsPostBack)
                {
                    if (Request["action"] == "add")
                    {
                        btnEdit.Visible = false;
                    }
                    if (Request["action"] == "update")
                    {
                        btnAdd.Visible = false;
                    }
                    if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
                    {
                        decimal PULLID = (Convert.ToDecimal(Request.Params["id"]));
                        ShowInfo(PULLID);
                    }
                }
            }
            catch (Exception ex)
            {
                lblMsg.Text = "错误信息：" + ex.Message;
            }
            #endregion
        }
        //更新时初始化
        private void ShowInfo(decimal PULLID)
        {
            BDPULLBLL bll = new BDPULLBLL();
            BDPULLModel model = bll.GetModel(PULLID);
            this.PULLID.Text = model.PULLID.ToString();
            this.CYJXH.Text = model.CYJXH;
            this.CYJLB.Text = model.CYJLB;
            this.SCCJ.Text = model.SCCJ;
            this.XDEDZH.Text = model.XDEDZH.ToString();
            this.GGZDCC.Text = model.GGZDCC.ToString();
            this.GGZDCCI.Text = model.GGZDCCI.ToString();
            this.JSQEDNJ.Text = model.JSQEDNJ.ToString();
            this.JSQXSDH.Text = model.JSQXSDH;
            this.PHFS.Text = model.PHFS;
            this.LGC.Text = model.LGC.ToString();
            this.QBC.Text = model.QBC.ToString();
            this.HBC.Text = model.HBC.ToString();
            this.QBZL.Text = model.QBZL.ToString();
            this.QBZXBJ.Text = model.QBZXBJ.ToString();
            this.QBZX.Text = model.QBZX;
            this.PDXHGG.Text = model.PDXHGG;
            this.PHKSL.Text = model.PHKSL.ToString();
            this.JSB.Text = model.JSB.ToString();
            this.ZJZL.Text = model.ZJZL.ToString();
            this.ZJCC.Text = model.ZJCC.ToString();
            this.JNCYJ.Text = model.JNCYJ;
            this.SCFS.Text = model.SCFS;
            this.JXFLM.Text = model.JXFLM;
            

        }

        //添加
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            #region
            try
            {
                string strErr = "";
                if (!PageValidate.IsDecimal(this.PULLID.Text))
                {
                    strErr += "PULLID格式错误！\\n";
                }
                if (this.CYJXH.Text.Trim().Length == 0)
                {
                    strErr += "CYJXH不能为空！\\n";
                }
                if (this.CYJLB.Text.Trim().Length == 0)
                {
                    strErr += "CYJLB不能为空！\\n";
                }
                if (this.SCCJ.Text.Trim().Length == 0)
                {
                    strErr += "SCCJ不能为空！\\n";
                }
                if (!PageValidate.IsDecimal(this.XDEDZH.Text))
                {
                    strErr += "XDEDZH格式错误！\\n";
                }
                if (!PageValidate.IsDecimal(this.GGZDCC.Text))
                {
                    strErr += "GGZDCC格式错误！\\n";
                }
                if (!PageValidate.IsDecimal(this.GGZDCCI.Text))
                {
                    strErr += "GGZDCCI格式错误！\\n";
                }
                if (!PageValidate.IsDecimal(this.JSQEDNJ.Text))
                {
                    strErr += "JSQEDNJ格式错误！\\n";
                }
                if (this.JSQXSDH.Text.Trim().Length == 0)
                {
                    strErr += "JSQXSDH不能为空！\\n";
                }
                if (this.PHFS.Text.Trim().Length == 0)
                {
                    strErr += "PHFS不能为空！\\n";
                }
                if (!PageValidate.IsDecimal(this.LGC.Text))
                {
                    strErr += "LGC格式错误！\\n";
                }
                if (!PageValidate.IsDecimal(this.QBC.Text))
                {
                    strErr += "QBC格式错误！\\n";
                }
                if (!PageValidate.IsDecimal(this.HBC.Text))
                {
                    strErr += "HBC格式错误！\\n";
                }
                if (!PageValidate.IsDecimal(this.QBZL.Text))
                {
                    strErr += "QBZL格式错误！\\n";
                }
                if (!PageValidate.IsDecimal(this.QBZXBJ.Text))
                {
                    strErr += "QBZXBJ格式错误！\\n";
                }
                if (this.QBZX.Text.Trim().Length == 0)
                {
                    strErr += "QBZX不能为空！\\n";
                }
                if (this.PDXHGG.Text.Trim().Length == 0)
                {
                    strErr += "PDXHGG不能为空！\\n";
                }
                if (!PageValidate.IsDecimal(this.PHKSL.Text))
                {
                    strErr += "PHKSL格式错误！\\n";
                }
                if (!PageValidate.IsDecimal(this.JSB.Text))
                {
                    strErr += "JSB格式错误！\\n";
                }
                if (!PageValidate.IsDecimal(this.ZJZL.Text))
                {
                    strErr += "ZJZL格式错误！\\n";
                }
                if (!PageValidate.IsDecimal(this.ZJCC.Text))
                {
                    strErr += "ZJCC格式错误！\\n";
                }
                if (this.JNCYJ.Text.Trim().Length == 0)
                {
                    strErr += "JNCYJ不能为空！\\n";
                }
                if (this.SCFS.Text.Trim().Length == 0)
                {
                    strErr += "SCFS不能为空！\\n";
                }
                if (this.JXFLM.Text.Trim().Length == 0)
                {
                    strErr += "JXFLM不能为空！\\n";
                }
               
               

                if (strErr != "")
                {
                    MessageBox.Show(this, strErr);
                    return;
                }
                decimal PULLID = decimal.Parse(this.PULLID.Text);
                string CYJXH = this.CYJXH.Text;
                string CYJLB = this.CYJLB.Text;
                string SCCJ = this.SCCJ.Text;
                decimal XDEDZH = decimal.Parse(this.XDEDZH.Text);
                decimal GGZDCC = decimal.Parse(this.GGZDCC.Text);
                decimal GGZDCCI = decimal.Parse(this.GGZDCCI.Text);
                decimal JSQEDNJ = decimal.Parse(this.JSQEDNJ.Text);
                string JSQXSDH = this.JSQXSDH.Text;
                string PHFS = this.PHFS.Text;
                decimal LGC = decimal.Parse(this.LGC.Text);
                decimal QBC = decimal.Parse(this.QBC.Text);
                decimal HBC = decimal.Parse(this.HBC.Text);
                decimal QBZL = decimal.Parse(this.QBZL.Text);
                decimal QBZXBJ = decimal.Parse(this.QBZXBJ.Text);
                string QBZX = this.QBZX.Text;
                string PDXHGG = this.PDXHGG.Text;
                decimal PHKSL = decimal.Parse(this.PHKSL.Text);
                decimal JSB = decimal.Parse(this.JSB.Text);
                decimal ZJZL = decimal.Parse(this.ZJZL.Text);
                decimal ZJCC = decimal.Parse(this.ZJCC.Text);
                string JNCYJ = this.JNCYJ.Text;
                string SCFS = this.SCFS.Text;
                string JXFLM = this.JXFLM.Text;
               

                BDPULLModel model = new BDPULLModel();
                model.PULLID = PULLID;
                model.CYJXH = CYJXH;
                model.CYJLB = CYJLB;
                model.SCCJ = SCCJ;
                model.XDEDZH = XDEDZH;
                model.GGZDCC = GGZDCC;
                model.GGZDCCI = GGZDCCI;
                model.JSQEDNJ = JSQEDNJ;
                model.JSQXSDH = JSQXSDH;
                model.PHFS = PHFS;
                model.LGC = LGC;
                model.QBC = QBC;
                model.HBC = HBC;
                model.QBZL = QBZL;
                model.QBZXBJ = QBZXBJ;
                model.QBZX = QBZX;
                model.PDXHGG = PDXHGG;
                model.PHKSL = PHKSL;
                model.JSB = JSB;
                model.ZJZL = ZJZL;
                model.ZJCC = ZJCC;
                model.JNCYJ = JNCYJ;
                model.SCFS = SCFS;
                model.JXFLM = JXFLM;
                model.ISVALID = 0;
                model.ISUSED = 0;
                model.BJ = "";


                BDPULLBLL bll = new BDPULLBLL();
                bll.Add(model);
                Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "PullManage.aspx");
            }
            catch (Exception ex)
            {
                lblMsg.Text = "错误信息：" + ex.Message;
            }
            #endregion
        }

        ////修改
        protected void btnEdit_Click(object sender, EventArgs e)
        {
            #region
            try
            {
                string strErr = "";
                if (!PageValidate.IsDecimal(this.PULLID.Text))
                {
                    strErr += "PULLID格式错误！\\n";
                }
                if (this.CYJXH.Text.Trim().Length == 0)
                {
                    strErr += "CYJXH不能为空！\\n";
                }
                if (this.CYJLB.Text.Trim().Length == 0)
                {
                    strErr += "CYJLB不能为空！\\n";
                }
                if (this.SCCJ.Text.Trim().Length == 0)
                {
                    strErr += "SCCJ不能为空！\\n";
                }
                if (!PageValidate.IsDecimal(this.XDEDZH.Text))
                {
                    strErr += "XDEDZH格式错误！\\n";
                }
                if (!PageValidate.IsDecimal(this.GGZDCC.Text))
                {
                    strErr += "GGZDCC格式错误！\\n";
                }
                if (!PageValidate.IsDecimal(this.GGZDCCI.Text))
                {
                    strErr += "GGZDCCI格式错误！\\n";
                }
                if (!PageValidate.IsDecimal(this.JSQEDNJ.Text))
                {
                    strErr += "JSQEDNJ格式错误！\\n";
                }
                if (this.JSQXSDH.Text.Trim().Length == 0)
                {
                    strErr += "JSQXSDH不能为空！\\n";
                }
                if (this.PHFS.Text.Trim().Length == 0)
                {
                    strErr += "PHFS不能为空！\\n";
                }
                if (!PageValidate.IsDecimal(this.LGC.Text))
                {
                    strErr += "LGC格式错误！\\n";
                }
                if (!PageValidate.IsDecimal(this.QBC.Text))
                {
                    strErr += "QBC格式错误！\\n";
                }
                if (!PageValidate.IsDecimal(this.HBC.Text))
                {
                    strErr += "HBC格式错误！\\n";
                }
                if (!PageValidate.IsDecimal(this.QBZL.Text))
                {
                    strErr += "QBZL格式错误！\\n";
                }
                if (!PageValidate.IsDecimal(this.QBZXBJ.Text))
                {
                    strErr += "QBZXBJ格式错误！\\n";
                }
                if (this.QBZX.Text.Trim().Length == 0)
                {
                    strErr += "QBZX不能为空！\\n";
                }
                if (this.PDXHGG.Text.Trim().Length == 0)
                {
                    strErr += "PDXHGG不能为空！\\n";
                }
                if (!PageValidate.IsDecimal(this.PHKSL.Text))
                {
                    strErr += "PHKSL格式错误！\\n";
                }
                if (!PageValidate.IsDecimal(this.JSB.Text))
                {
                    strErr += "JSB格式错误！\\n";
                }
                if (!PageValidate.IsDecimal(this.ZJZL.Text))
                {
                    strErr += "ZJZL格式错误！\\n";
                }
                if (!PageValidate.IsDecimal(this.ZJCC.Text))
                {
                    strErr += "ZJCC格式错误！\\n";
                }
                if (this.JNCYJ.Text.Trim().Length == 0)
                {
                    strErr += "JNCYJ不能为空！\\n";
                }
                if (this.SCFS.Text.Trim().Length == 0)
                {
                    strErr += "SCFS不能为空！\\n";
                }
                if (this.JXFLM.Text.Trim().Length == 0)
                {
                    strErr += "JXFLM不能为空！\\n";
                }



                if (strErr != "")
                {
                    MessageBox.Show(this, strErr);
                    return;
                }
                decimal PULLID = decimal.Parse(this.PULLID.Text);
                string CYJXH = this.CYJXH.Text;
                string CYJLB = this.CYJLB.Text;
                string SCCJ = this.SCCJ.Text;
                decimal XDEDZH = decimal.Parse(this.XDEDZH.Text);
                decimal GGZDCC = decimal.Parse(this.GGZDCC.Text);
                decimal GGZDCCI = decimal.Parse(this.GGZDCCI.Text);
                decimal JSQEDNJ = decimal.Parse(this.JSQEDNJ.Text);
                string JSQXSDH = this.JSQXSDH.Text;
                string PHFS = this.PHFS.Text;
                decimal LGC = decimal.Parse(this.LGC.Text);
                decimal QBC = decimal.Parse(this.QBC.Text);
                decimal HBC = decimal.Parse(this.HBC.Text);
                decimal QBZL = decimal.Parse(this.QBZL.Text);
                decimal QBZXBJ = decimal.Parse(this.QBZXBJ.Text);
                string QBZX = this.QBZX.Text;
                string PDXHGG = this.PDXHGG.Text;
                decimal PHKSL = decimal.Parse(this.PHKSL.Text);
                decimal JSB = decimal.Parse(this.JSB.Text);
                decimal ZJZL = decimal.Parse(this.ZJZL.Text);
                decimal ZJCC = decimal.Parse(this.ZJCC.Text);
                string JNCYJ = this.JNCYJ.Text;
                string SCFS = this.SCFS.Text;
                string JXFLM = this.JXFLM.Text;


                BDPULLModel model = new BDPULLModel();
                model.PULLID = PULLID;
                model.CYJXH = CYJXH;
                model.CYJLB = CYJLB;
                model.SCCJ = SCCJ;
                model.XDEDZH = XDEDZH;
                model.GGZDCC = GGZDCC;
                model.GGZDCCI = GGZDCCI;
                model.JSQEDNJ = JSQEDNJ;
                model.JSQXSDH = JSQXSDH;
                model.PHFS = PHFS;
                model.LGC = LGC;
                model.QBC = QBC;
                model.HBC = HBC;
                model.QBZL = QBZL;
                model.QBZXBJ = QBZXBJ;
                model.QBZX = QBZX;
                model.PDXHGG = PDXHGG;
                model.PHKSL = PHKSL;
                model.JSB = JSB;
                model.ZJZL = ZJZL;
                model.ZJCC = ZJCC;
                model.JNCYJ = JNCYJ;
                model.SCFS = SCFS;
                model.JXFLM = JXFLM;
                model.ISVALID = 0;
                model.ISUSED = 0;
                model.BJ = "";


                BDPULLBLL bll = new BDPULLBLL();
                bll.Update(model);
                Maticsoft.Common.MessageBox.ShowAndRedirect(this, "修改成功！", "PullManage.aspx");
            }
            catch (Exception ex)
            {
                lblMsg.Text = "错误信息：" + ex.Message;
            }
            #endregion

        }
    }
}